package com.gzx.bi.modular.screen.controller;

import com.gzx.bi.modular.screen.service.GzxBICallRecordService;
import com.gzx.bi.modular.screen.service.GzxStatisticBIService;
import com.gzx.bi.modular.screen.vo.GzxStatisticBIVo;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import vip.xiaonuo.common.pojo.CommonResult;

/**
 * bi报表控制器
 *
 * @author xbl
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/bi/screen")
public class GzxStatisticBIController {

    private final GzxStatisticBIService service;

    private final GzxBICallRecordService biCallRecordService;

    /**
     * 根据报表类型获取报表结果
     */
    @GetMapping("/getResultByType/{type}")
    public CommonResult<GzxStatisticBIVo> getResultByType(@PathVariable("type") String type) {
        return CommonResult.data(service.getResultByType(type));
    }

    /**
     * 跑当月所有报表数据
     */
    @GetMapping("/runBI")
    public CommonResult<Void> runBI() {
        return CommonResult.data(biCallRecordService.runBI());
    }

    /**
     * 跑某天报表数据
     */
    @GetMapping("/runDateBI/{currentDate}")
    public CommonResult<Void> runDateBI(@PathVariable("currentDate") String currentDate) {
        return CommonResult.data(biCallRecordService.runDateBI(currentDate));
    }
}
